Repository navigation
feat(codegen-ts): keep the hash manifest as one file per model package - #617
Merged
Merged
Conversation
Parallel branches that regenerate files in different packages no longer conflict on a single .gen-state/.hashes.json. The manifest is now .gen-state/.hashes/<package>.json, with .root.json for a path in no package, in every port that keeps hash state (TypeScript, C#, Java, Kotlin, Python, Rust). - ADR-0064 Amendment 1 records the layout, the file naming, the placement rules (sourceNode, then the model object a file name starts with by words, then the file it was read from, then root), the write-only-what-changed rule and the migration. - fixtures/codegen-skip-conformance/manifests.json holds the shared vectors, and a legacy-manifest case in cases.json holds every port to the migration: a run that finds the legacy file splits it, deletes it and adds the gitignore negation; verify never migrates. - Placement only decides which file holds an entry. Readers merge every file, so a wrong placement costs a merge conflict and nothing else. - A test merges two real git branches that change different packages with no conflict. - CHANGELOG lists it under "Upgrading from 1.2.0" for 1.3.0, with a migration guide.
- Rust keeps .root.json only when the manifest holds no entry at all (ADR-0064 Amendment 1 section 4), matching the other ports. - Java feeds only root-level objects into the stem index, as the other ports do, and touches .metaobjects/.gitignore only when it migrates a legacy manifest. - Migration replaces the dead `!.gen-state/.hashes.json` negation with `!.gen-state/.hashes/` in every port (shared vector updated), instead of leaving both. - The JVM, TypeScript and 1.0-to-1.1 migration guides name the directory in their commands and ignore rules, so following them no longer git-ignores `.hashes/`. - The four example projects carry their migrated `.hashes/` manifest. - The Python no-op save test now re-records identical content and checks no file changes, instead of setting its own flag.
… unresolved findings.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What Changed
.metaobjects/.gen-state/.hashes.jsonwith a.hashes/directory holding one JSON file per model package (<package>.json, with.root.jsonfor paths in no package). Parallel branches that regenerate different packages no longer conflict on one file. Applied in every port that keeps hash state: TypeScript (codegen-tshash-manifest-store.ts), C#, Java and Kotlin (codegen-baseHashManifest), Python, and Rust (preview). Placement is a pure function of each entry's recorded source node or owning object name, and readers merge all package files with the legacy file underneath.genafter upgrade, the legacy.hashes.jsonis read, the package files are written, the legacy file is removed, and!.gen-state/.hashes/is added to.metaobjects/.gitignorewhen the old negation is present. Writes touch only files whose bytes change. The TypeScript skip decision refuses to skip while a legacy manifest is still present, so the migration run always writes.verifyreads the manifest without migrating it.fixtures/codegen-skip-conformance/manifests.json, plus alegacy-manifestcase) hold each port to the same placement and migration behavior. Adds a TypeScript branch-merge test that merges two git branches changing different packages without conflict. Documents the change in ADR-0064 Amendment 1,docs/features/migrations/per-package-hash-manifest.md, and updates the existing hash-manifest migration guides and CHANGELOG (metamodelVersionis unchanged).Validation
Risk Assessment
✅ Low: Per-package manifest placement is a pure function with a union reader, so misplacement costs only a merge conflict. Legacy migration, skip bypass, gitignore rewrite and dry-run handling hold in the ports I traced, and the migrated example manifests keep identical entries. I did not read every test, doc or fixture file in the diff, and I ran no tests. Only a stale test helper was found.
Testing
Three live scenarios passed against the real TypeScript meta CLI in disposable projects: fresh per-package layout, parallel two-branch merge with a clean post-merge gen and verify, and migration of a legacy single .hashes.json written by the base-commit CLI. The adversarial fresh-clone hand-edit refusal also passed inside the parallel-branch run. The old-layout conflict control was not reproduced: the two-entry harness merged clean on base too, so the before/after conflict claim rests on reasoning and the adopter report. Broad regression came from the configured scripts/ci-local.sh --affected --strict-toolchains run, which passed at this commit. Evidence transcript:
bun server/typescript/packages/cli/bin/meta.ts genin a disposable meta-init p…Evidence: Per-package hash manifest scenario transcript (fresh layout, parallel merge with adversarial fresh-clone refusal, legacy migration)
Pipeline
Updates from git push no-mistakes
✅ **Intent** - passed
✅ No issues found.
✅ **Rebase** - passed
✅ No issues found.
server/python/tests/codegen/test_cli_config_verify.py:133- The_record_as_writtenhelper still writes the legacy single-file.gen-state/.hashes.json. The test passes only because readers still merge the legacy file underneath the package files. Sotest_verify_codegen_shared_outdir_detects_stale_extraand its siblings never exercise the new.hashes/<package>.jsonlayout for the verify path.server/python/tests/codegen/manifest_helpers.pywas added in this change for this purpose, so the helper should write through it. (The JavaConfiguredGeneratorsTestlegacy fixture at line 516 is deliberate, since it models a pre-release manifest.).metaobjects/.gen-state/.fingerprint-typescript.json- The .metaobjects/.gen-state/.fingerprint-typescript.json file is still one shared file per project and is rewritten whenever the model changes. Init's .metaobjects/.gitignore ignores it, so projects scaffolded by meta init are unaffected. Projects without that .gitignore that track gen-state will still conflict on it when branches change the model. That behaviour predates this change, and the intent names only .hashes.json. No change requested.bun server/typescript/packages/cli/bin/meta.ts genin a disposable meta-init p…scripts/ci-local.sh --affected --strict-toolchainsbun server/typescript/packages/cli/bin/meta.ts init in a disposable scratch project (synthetic two-package model, entityFile generator)bun server/typescript/packages/cli/bin/meta.ts gen on a fresh project: exit 0, per-package manifest files written, no .hashes.jsonTwo-branch parallel edit (branch-a in acme::commerce, branch-b in acme::users) merged with git merge in a disposable repo: both exit 0, no unmerged pathsPost-merge meta gen (both files unchanged) and meta verify --codegen (exit 0)Fresh git clone of the disposable repo, hand edit to a generated file, meta gen: exit 1, file refused by name, unedited file unchangedLegacy upgrade: base-commit 333ccc60d CLI extracted with git archive wrote a .hashes.json; new CLI meta gen exit 0, outputs unchanged, legacy file removed, per-package files writtenDriver script ran end-to-end; transcript saved to evidence; scratch projects removed afterwards; no background processes startedBroad regression came from the configured test command scripts/ci-local.sh --affected --strict-toolchains, which passed at this target commit. Not re-run here because no source or test files were changed in this turn.✅ **Document** - passed
✅ No issues found.
✅ **Lint** - passed
✅ No issues found.
✅ **Push** - passed
✅ No issues found.